Skip to content

Add Octavia project quota limits and resource usage reads - #2

Merged
legit-ninja merged 5 commits into
mainfrom
contrib/octavia-quotas-2b2
Dec 4, 2026
Merged

legit-ninja merged 5 commits into
mainfrom
contrib/octavia-quotas-2b2

Conversation

@davidhulick

Copy link
Copy Markdown

Add Octavia project quota limits and resource usage reads

Summary

Add read-only Octavia quota queries and repository methods for project quota limits, resource counts, and reconstructed quota usage across all seven Octavia resource types.

Changes

  • Expose stored project quota limits, preserving nullable values.
  • Add per-project load balancer, listener, and pool counts.
  • Add usage accounting for load balancers, listeners, pools, health monitors, members, L7 policies, and L7 rules.
  • Count non-DELETED resources using each object's own project and provisioning status, including relevant ERROR and pending states.
  • Preserve usage-only projects and avoid parent joins that could multiply or suppress counts.
  • Add sqlc-generated methods/models, test fixtures, Go unit tests, MariaDB integration tests, and portable Python SQL tests.
  • Register the existing MySQL driver explicitly for standalone integration tests.
  • Enable Python SQL-test discovery in GitHub Actions.

The changes are additive and preserve existing Octavia repository behavior. Schema additions are for code generation and testing, not production database migrations.

ConnectContext pings and closes the pool when the database does not
answer, so a caller that starts during a database outage has no pool
at all. The OpenStack database exporter then reports its services as
down until it is restarted, even after the database is back.

Open does the parsing and pool setup without contacting the server,
and ConnectContext becomes Open plus the ping, so existing callers
behave as before. The pool connects on first use and reconnects
after a lost connection.

Tested with go test -race, go vet, gofmt and the integration suite.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Timon Schnell <timon.schnell@btc-it-services.com>

@adamhackl adamhackl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Counting each table independently, with no parent joins, is the right call, and the README is clear about how this differs from Octavia’s own counters. A few things:

  1. Consider also exposing the cached in_use_* columns
    GetUsage rebuilds counts from objects, but Octavia enforces quota against the cached in_use_* counters on the quotas table. When those drift, a project can be refused by Octavia while our metrics still show headroom, or the other way round. Returning the cached values next to the rebuilt counts would let consumers show what’s actually enforced and alert on drift. As written, that difference can’t be seen through the library.

  2. Two sources of truth for some counts
    LoadBalancerCountByProject, ListenerCountByProject and PoolCountByProject repeat three of the seven arms of QuotaUsageGetAll. If someone later changes one predicate and not the other, the two APIs will report different numbers for the same thing. Is there a consumer that needs the per-resource versions? If not, I’d drop them. If they’re needed, what about the other four resources?

  3. Query cost on real schemas
    QuotaUsageGetAll fully scans all seven tables on every call. member and l7rule can be large in busy deployments. Has anyone checked the query plan against a real Octavia schema to see whether project_id / provisioning_status are indexed?

  4. Owner filtering
    QuotaGetAll keeps an empty-string project row, but the usage queries exclude it. That’s the same pattern as #4, so consumers joining limits to usage will have an unmatched row. Please align them, or note why the difference is intentional.

@etimmons etimmons left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That QuotaUsageGetAll query looks heavy with the UNION ALLs along with the WHERE clause on columns without an index. Probably not a problem now, but something to keep an eye on in the future.

Open adds no dial timeout, so a pool held through a database outage
does not fail fast. Say so in the Open doc comment and the README,
and move the Open note into its own README paragraph.

Signed-off-by: Mohammed Naser <mnaser@vexxhost.com>
Add Open for a pool without the startup ping
fitbeard and others added 2 commits December 1, 2026 10:52
Add three read-only Designate queries for openstack_database_exporter:

- ZoneGetAll: non-deleted zones with status and type.
- RecordsetCountByZone: recordset count per non-deleted zone, including
  zones with no recordsets, without reading individual records.
- RecordsetGetAllWithStatus: recordsets with the status the Designate API
  reports (worst child record status in the order ERROR, PENDING, ACTIVE,
  DELETED; ACTIVE when a recordset has no records).

Zone and recordset IDs are returned as dashed UUIDs, matching the API.
Splitting the queries lets the exporter skip the per-recordset status
query when that metric is disabled.

Signed-off-by: Tadas Sutkaitis <tadas.sutkaitis@vexxhost.com>
Add two read-only Octavia quota queries and a QuotaRepository that wraps
them:

- QuotaGetAll (QuotaRepository.GetAll): one row per project from the
  quotas table, with the stored limits for all seven quota resources
  and Octavia's cached in_use_* counters, which check_quota_met and
  decrement_quota enforce against. Limits and counters are nullable;
  NULL, zero and -1 limits are returned as stored.
- QuotaUsageGetAll (QuotaRepository.GetUsage): recounts load balancers,
  listeners, pools, members, health monitors, L7 policies and L7 rules
  per project with check_quota_met's predicate (the object's own
  project_id and provisioning_status != 'DELETED'). Each table is
  counted independently, so no parent join can multiply or drop
  counts, and projects without quota rows are included.

Comparing the two reads shows counter drift. Octavia defines no index on
project_id or provisioning_status, so the recount scans all seven
object tables and suits a less frequent drift check rather than every
scrape. Both reads exclude empty project IDs, which Octavia rejects.

Add the quota and object tables to the Octavia schema fixture, unit
tests, a MariaDB integration test with a fixture covering matching and
drifted counters, smoke calls in TestOctaviaQueries, and API.md
documentation.

Co-authored-by: David Hulick <dave.hulick@gmail.com>
Signed-off-by: David Hulick <dave.hulick@gmail.com>
Signed-off-by: Jeremy Lee <jeremy.lee1664@gmail.com>
@legit-ninja
legit-ninja force-pushed the contrib/octavia-quotas-2b2 branch from e5d6e1b to d0c9d48 Compare December 3, 2026 17:54
@legit-ninja
legit-ninja merged commit d8357e8 into main Dec 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants